package com.app.business.show;

import com.app.business.model.AzProject;
import com.app.business.model.House;
import com.app.business.service.*;
import com.app.system.permission.service.DataDictService;
import com.app.system.utils.ParamUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.RequestMapping;

import javax.servlet.http.HttpServletRequest;
import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Map;

/**
 * 大屏公示（没有权限限制）
 * Created by ddz on 2022/9/21.
 */
@Controller
@RequestMapping("/showForHjTwo/*")
@SuppressWarnings("all")
public class ShowForHjTwoController {
    @Autowired
    private ContractService contractService;
    @Autowired
    private ZsProjectService zsProjectService;
    @Autowired
    private AzProjectService azProjectService;
    @Autowired
    private DataDictService dataDictService;
    @Autowired
    private ShowHjService showHjService;
    @Autowired
    private HouseService houseService;
    @Autowired
    private CarLotService carLotService;
    @Autowired
    private StorageRoomService storageRoomService;
    @Autowired
    private StatisticsService statisticsService;


    /**
     * 大屏主界面
     */
    @RequestMapping("tv")
    public void tv(ModelMap modelMap) {
    }

    /**
     * 获取房源数据
     *
     * @param request
     * @return
     */
    @RequestMapping("houseHoldMapData")
    public void houseHoldMapData(HttpServletRequest request, ModelMap modelMap) {
        String zsProjectIdStr = ParamUtils.getString(request, "zsProjectIdStr", "");
        String azProjectIdStr = ParamUtils.getString(request, "azProjectIdStr", "");
        Map<String, Map<String, Map<String, Map>>> houseHoldDataMap = this.houseService.getHouseHoldMap(zsProjectIdStr, azProjectIdStr);
        Map<String, String> houseHoldMap = this.dataDictService.getMapByParentNameForValue_Name("房屋户型");
        Map<String, AzProject> azProjectMap = this.azProjectService.getAzProjectMap();
        modelMap.addAttribute("houseHoldDataMap", houseHoldDataMap);
        modelMap.addAttribute("houseHoldMap", houseHoldMap);
        modelMap.addAttribute("azProjectMap", azProjectMap);
    }


    /**
     * 楼盘图
     *
     * @param request
     */
    @RequestMapping("housePic")
    public void housePic(HttpServletRequest request, ModelMap modelMap) {
        String zsProjectIdStr = ParamUtils.getString(request, "zsProjectIdStr", "");
        Integer azProjectId = ParamUtils.getInt(request, "azProjectId", 0);
        String buildNum = ParamUtils.getString(request, "buildNum", "");
        String houseStyle = ParamUtils.getString(request, "houseStyle", "");
        String houseHold = ParamUtils.getString(request, "houseHold", "");
        String buildArea = ParamUtils.getString(request, "buildArea", "");

        //通过征收项目、安置项目、楼号得到所分配的houseList
        Map<String, List> houseMap = showHjService.houseMap(zsProjectIdStr, azProjectId, buildNum, houseHold, houseStyle, buildArea,null);


        //房源状态
        Map<String, String> colorMap = this.dataDictService.getMapByParentNameForValue_Color("公示颜色");
        //房屋类型
        Map<String, String> houseHoldMap = this.dataDictService.getMapByParentNameForValue_Name("房屋户型");
        modelMap.addAttribute("colorMap", colorMap);
        modelMap.addAttribute("houseHoldMap", houseHoldMap);
        List<String> buildNumList = Arrays.asList(buildNum.replace("(", "").replace(")", "").replace("'", "").split(","));
        modelMap.addAttribute("buildNumList", buildNumList);
        modelMap.addAttribute("houseMap", houseMap);
    }



    /**
     * 湖滨二期
     */
    @RequestMapping("houseShowHjTwo1")
    public void houseShowHjTwo1(HttpServletRequest request, ModelMap modelMap) {
        Map<String, String> colorMap = this.dataDictService.getMapByParentNameForValue_Color("公示颜色");
        modelMap.addAttribute("colorMap", colorMap);
    }

    /**
     * 湖滨二期
     */
    @RequestMapping("houseShowHjTwo2")
    public void houseShowHjTwo2(HttpServletRequest request, ModelMap modelMap) {
        Map<String, String> colorMap = this.dataDictService.getMapByParentNameForValue_Color("公示颜色");
        modelMap.addAttribute("colorMap", colorMap);
    }

    /**
     * 湖滨二期
     */
    @RequestMapping("houseShowHjTwo3")
    public void houseShowHjTwo3(HttpServletRequest request, ModelMap modelMap) {
        Map<String, String> colorMap = this.dataDictService.getMapByParentNameForValue_Color("公示颜色");
        modelMap.addAttribute("colorMap", colorMap);
    }

    /**
     * 湖滨二期
     */
    @RequestMapping("houseShowHjTwo4")
    public void houseShowHjTwo4(HttpServletRequest request, ModelMap modelMap) {
        Map<String, String> colorMap = this.dataDictService.getMapByParentNameForValue_Color("公示颜色");
        modelMap.addAttribute("colorMap", colorMap);
    }

    /**
     * 湖滨二期
     */
    @RequestMapping("houseShowHjTwo5")
    public void houseShowHjTwo5(HttpServletRequest request, ModelMap modelMap) {
        Map<String, String> colorMap = this.dataDictService.getMapByParentNameForValue_Color("公示颜色");
        modelMap.addAttribute("colorMap", colorMap);
    }

    /**
     * 湖滨二期
     */
    @RequestMapping("houseShowHjTwo6")
    public void houseShowHjTwo6(HttpServletRequest request, ModelMap modelMap) {
        Map<String, String> colorMap = this.dataDictService.getMapByParentNameForValue_Color("公示颜色");
        modelMap.addAttribute("colorMap", colorMap);
    }

    /**
     * 湖滨二期
     */
    @RequestMapping("houseShowHjTwo7")
    public void houseShowHjTwo7(HttpServletRequest request, ModelMap modelMap) {
        Map<String, String> colorMap = this.dataDictService.getMapByParentNameForValue_Color("公示颜色");
        modelMap.addAttribute("colorMap", colorMap);
    }

    /**
     * 湖滨二期
     */
    @RequestMapping("houseShowHjTwo8")
    public void houseShowHjTwo8(HttpServletRequest request, ModelMap modelMap) {
        Map<String, String> colorMap = this.dataDictService.getMapByParentNameForValue_Color("公示颜色");
        modelMap.addAttribute("colorMap", colorMap);
    }
    /**
     * 湖滨二期
     */
    @RequestMapping("houseShowHjTwo9")
    public void houseShowHjTwo9(HttpServletRequest request, ModelMap modelMap) {
        Map<String, String> colorMap = this.dataDictService.getMapByParentNameForValue_Color("公示颜色");
        modelMap.addAttribute("colorMap", colorMap);
    }
    /**
     * 湖滨二期
     */
    @RequestMapping("houseShowHjTwo10")
    public void houseShowHjTwo10(HttpServletRequest request, ModelMap modelMap) {
        Map<String, String> colorMap = this.dataDictService.getMapByParentNameForValue_Color("公示颜色");
        modelMap.addAttribute("colorMap", colorMap);
    }
    /**
     * 湖滨二期
     */
    @RequestMapping("houseShowHjTwo11")
    public void houseShowHjTwo11(HttpServletRequest request, ModelMap modelMap) {
        Map<String, String> colorMap = this.dataDictService.getMapByParentNameForValue_Color("公示颜色");
        modelMap.addAttribute("colorMap", colorMap);
    }
    /**
     * 湖滨二期
     */
    @RequestMapping("houseShowHjTwo12")
    public void houseShowHjTwo12(HttpServletRequest request, ModelMap modelMap) {
        Map<String, String> colorMap = this.dataDictService.getMapByParentNameForValue_Color("公示颜色");
        modelMap.addAttribute("colorMap", colorMap);
    }
    /**
     * 楼盘图
     *
     * @param request
     */
    @RequestMapping("housePicAll")
    public void housePicAll(HttpServletRequest request, ModelMap modelMap) {
        this.housePic(request, modelMap);
    }
}
